package control;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import entity.Setting;
import service.SetService;
import service.SetServiceimpl;

public class Getset  extends HttpServlet{
	SetService svc=new SetServiceimpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String email = null;
		Integer typeid = null;;
		String password = null;
		for(Cookie c:req.getCookies()) {
			if(c.getName().equals("email")) {
				email = c.getValue();
			}
			if(c.getName().equals("typeid")) {
				typeid = Integer.valueOf(c.getValue());
			}
			if(c.getName().equals("password")) {
				password = c.getValue();
			}
		}
		Setting set=null;
		try {
			 set = svc.getset(email);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		resp.setCharacterEncoding("utf-8");
		System.out.println(set);
		resp.getWriter().print(JSON.toJSONString(set));
	}
	
}
